﻿// <copyright file="CandleControl.cs" company="Golizza.net">Copyright (c) 2012 All Right Reserved</copyright>

namespace ClientApp.Control
{
    using System.Windows;
    using System.Windows.Controls;
    using ClientApp.Model;

    /// <summary>
    /// The control use to present 1 candle in chart.
    /// </summary>
    public class CandleControl : Control
    {
        #region [ Register Dependency Properties ]

        /// <summary>
        /// Identifies the <see cref="Candle"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty CandleProperty = DependencyProperty.Register("Candle", typeof(Tick), typeof(CandleControl));

        /// <summary>
        /// Identifies the <see cref="Minimum"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(CandleControl));

        /// <summary>
        /// Identifies the <see cref="Maximum"/> dependency property.
        /// </summary>
        public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(CandleControl));

        #endregion

        #region [ Constructors ]

        /// <summary>
        /// Initializes static members of the <see cref="CandleControl" /> class.
        /// </summary>
        static CandleControl()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CandleControl), new FrameworkPropertyMetadata(typeof(CandleControl)));
        }

        #endregion

        #region [ Dependency Properties ]

        /// <summary>
        /// Gets or sets the candle model.
        /// </summary>
        public Tick Candle
        {
            get
            {
                return this.GetValue(CandleControl.CandleProperty) as Tick;
            }

            set
            {
                this.SetValue(CandleControl.CandleProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the minimum value.
        /// </summary>
        public double Minimum
        {
            get
            {
                return (double)this.GetValue(CandleControl.MinimumProperty);
            }

            set
            {
                this.SetValue(CandleControl.MinimumProperty, value);
            }
        }

        /// <summary>
        /// Gets or sets the minimum value.
        /// </summary>
        public double Maximum
        {
            get
            {
                return (double)this.GetValue(CandleControl.MaximumProperty);
            }

            set
            {
                this.SetValue(CandleControl.MaximumProperty, value);
            }
        }

        #